package top.lyc829.mymusic.ui.fragment.login.phone

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import top.lyc829.mymusic.base.BaseViewModel
import top.lyc829.mymusic.model.http.MyNetwork
import top.lyc829.mymusic.model.repository.AuthRepository

class PhoneLoginViewModel : BaseViewModel() {

    private var repository : AuthRepository = AuthRepository.getInstance(MyNetwork.getInstance())

    private val _loginState: MutableLiveData<Boolean> by lazy { MutableLiveData() }
    val loginState: LiveData<Boolean> get() = _loginState

    fun doLogin(phone: String, password: String) {
        launch(true, {
            val banners = repository.login(phone, password)
            _loginState.value = true
        }, {
            errorLiveData.value = it
        })

    }


}